# -*- coding: UTF-8 -*-
import yun_mqtt
import utime as time
import yun_network
import state_led
from modem import info as infos


def main():
    state_led.led_disp_thread()         #状态灯线程
    ret = yun_network.connect_network()      #联网
    print("ret:",ret)
    if ret == True:
        yun_mqtt.mqtt_connect()         #连接云平台
    else:
        print('network-connection failed')

    
    n= 0
    while True:
        yun_mqtt.http_ota()         #重复检测云端是否有OTA命令下发
        n +=1
        if n > 100:                 #每100秒打印数字，判断代码运行
            print(n)
            n = 0
        time.sleep(1)
    

if __name__ == '__main__':
    sys_version=infos.getDevFwVersion()
    print(sys_version)
    main()

